/*
 *  $Id: RaiseDead.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Darkness.Spells {
    public class RaiseDead: SpellCard<GraveyardData> {
        public RaiseDead(): base("001_d_s_raise_dead") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Darkness;
            Value = 100;
            Target = new GraveyardTarget(GetTargetPhrase(), true, false, IsPossibleCost);
            AddManaCost(ElementType.Darkness, 3);
            AddCondition(new CreaturesCondition(true, 1));
            AddCondition(new GraveyardCondition(false, false, 1));
        }

        private static bool IsPossibleCost(TargetRequest request, GraveyardItem item) {
            return item.CanResurrect && item.Card.GetSumMana() < 5;
        }

        protected override void DoAction(TargetArgs<GraveyardData> args) {
            int place = args.Player.GetRandomFreePlace();
            if (place < 0) return;
            Creature cr = args.Player.ResurrectCreature(args.Target.Item, place, true);
            if (cr == null) return;
            if (!cr.IsUndead) cr.AddAffect(new Affects.Scorch(1));
        }
    }
}
